var app = getApp();
var api = require('../../utils/util.js');
Page({
    data: {
        currentTab: 1,
        cash_list: [],
        show_no_data_tip: !1,
        task: [],
        recommendedTask:[],
        screening: 1,
        userId: 0
    },
    /**
    * 生命周期函数--监听页面加载
    */
    onLoad: function (options) {
      this.setData({
        userId: wx.getStorageSync("userId"),
      })
      //获取手机高度
      this.setData({
        navH: app.globalData.navHeight
      })
      if (options.partnerUserId == undefined) {
        this.setData({
          partnerUserId: 0
        })
      } else {
        this.setData({
          partnerUserId: options.partnerUserId
        })
      }
      this.setData({
        type: options.type
      })
    },
  /**
 * 页面分享
 */
  onShareAppMessage: function () {
    var that = this;
    return {
      title: that.data.title,
      desc: '分享页面的内容',
      imageUrl: "http://file.jwsxmall.com/shareImg.jpg",
      path: '/pages/myPage/myPage?partnerUserId=' + wx.getStorageSync("userId") + '&type=0', // 路径，传递参数到指定页面
   
    }
  },
    //页面加载
    onReady: function() {
      var that = this;
      wx.request({
        url: app.globalData.url + "getUserPointHistory",
        header: {
          "content-type": "application/x-www-form-urlencoded"
        }, 
        data: {
          userId:that.data.userId,
          token: that.data.token
        },
        method: "POST",
        success: function (res) {
          var data = res.data;
          if (data.result === 1) {
            if (res.data.token != "" && res.data.token != undefined) {
              wx.setStorageSync("token", res.data.token)
            }
            that.setData({
              commission:data.data.reverse()
            })
            console.info(that.data.commission.taskName);
          }
          if (res.data.result == 9) {
            wx.reLaunch({
              url: '/pages/zcuslist/index',
            })
            return false;
          }
        }
      });
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var s = this;
        is_loading || is_no_more || (is_loading = !0, getApp().request({
            url: getApp().api.share.cash_detail,
            data: {
                status: s.data.status,
                page: p
            },
            success: function(t) {
                if (0 == t.code) {
                    var a = s.data.cash_list.concat(t.data.list);
                    s.setData({
                        cash_list: a
                    }), 0 == t.data.list.length && (is_no_more = !0);
                }
                p++;
            },
            complete: function() {
                is_loading = !1;
            }
        }));
  },
  onShow:function(){
    var that = this;
    that.setData({
      token: wx.getStorageSync("token"),
      points: wx.getStorageSync("points"),
    });
    api.authorization(0, that.data.partnerUserId);
  },
  gopointOrder: function () {
    wx.navigateTo({
      url: '/pages/integralOrderList/integralOrderList',
    })
  },
  goSignIn: function () {
    wx.navigateTo({
      url: '/pages/checkIn/checkIn',
    })
  },
  goPointShop: function () {
    wx.navigateTo({
      url: '/pages/integralMall/integralMall',
    })
  },
  navBack: function () {
    wx.navigateBack({

    })
  }
});